package ooday01;

public class Student {
     private String name;
     private int age;
     private int id;
     private String className;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public Student() {
    }

    public Student(String name, int age, int id, String className) {
        this.name = name;
        this.age = age;
        this.id = id;
        this.className = className;
    }
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", id=" + id +
                ", className='" + className + '\'' +
                '}';
    }

    void study(){
        System.out.println(name+"同学在"+className+"学习");
    }
    void sleep(){
        System.out.println(name+"同学正在睡觉");
    }
    void studentInformation(){
        System.out.println(name+"同学的id为："+id+",年龄为："+age+"，班级为："+className);
    }
    void playWith(String studentsName){
        System.out.println(name+"同学正在跟"+studentsName+"同学玩耍");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Student)) return false;

        Student student = (Student) o;

        if (getAge() != student.getAge()) return false;
        if (getId() != student.getId()) return false;
        if (getName() != null ? !getName().equals(student.getName()) : student.getName() != null) return false;
        return getClassName() != null ? getClassName().equals(student.getClassName()) : student.getClassName() == null;
    }

    @Override
    public int hashCode() {
        int result = getName() != null ? getName().hashCode() : 0;
        result = 31 * result + getAge();
        result = 31 * result + getId();
        result = 31 * result + (getClassName() != null ? getClassName().hashCode() : 0);
        return result;
    }
}


